<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>3.类型之间互相帮助才是好兄弟</title>
</head>

<body>
  <script>
    // set转数组 的两种方法: 点语法 Array.from
    let set = new Set(['hdcms', 'houdunren']);
    // console.log(Array.from(set)); //(2) ['hdcms', 'houdunren']
    //console.log([...set]); //(2) ['hdcms', 'houdunren']
    let hd = new Set('123456789');
    console.log(hd); //Set(9) {'1', '2', '3', '4', '5', …}
    // 保留大于5的元素, set没有对应的afi可以转成array 
    hd = new Set([...hd].filter(item => item < 5));
    console.log(hd);//Set(4) {'1', '2', '3', '4'}
    // 数组去重，可以利用set 特性
    let array = [1,2,3,4,5,2,3,1];
    console.log([...new Set(array)]); //(5) [1, 2, 3, 4, 5]
  </script>
</body>

</html>